<!--
 * @Author: WLang
 * @LastEditors: WLang
 * @Description: 
 * @Date: 2023-07-25 23:21:43
 * @LastEditTime: 2023-07-25 23:34:57
 * @FilePath: \my-wyy\src\components\svgIcon.vue
-->
<template>
  <svg :class="svgClass" aria-hidden="true">
    <use :xlink:href="computedIconName" />
  </svg>
</template>
<script>
export default {
  name: 'SvgIcon',
  props: {
    //传入iconName
    iconName: {
      type: String,
      required: true
    },
    // class
    className: {
      type: String,
      default: ''
    }
  },
  computed: {
    computedIconName() {
      return `#icon-${this.iconName}`
    },
    svgClass() {
      if (this.className) {
        return 'svg-icon ' + this.className
      } else {
        return 'svg-icon'
      }
    }
  }
}
</script>
<style lang="scss" scoped>
.svg-icon {
  width: 1em;
  height: 1em;
  vertical-align: -0.15em;
  fill: currentColor;
  overflow: hidden;
}
</style>